$pos = 828;
$end = 81194907;
$temp=$pos;
$i=0;
open(WRBUFF,"|gzip > /data4/bsi/RandD/Workflow/temp/temp.s112629/redo_22/graphs/beagle17.dosage.gz") or die "no file exists\n";
while($temp < $end)
{
	$i++;
	$start=$temp;
        #print $temp;
        $temp=$temp+5000000;
	$stop=$temp;
        #print "\t$temp\n";
        #$sys = "awk -F ' ' '{if(\$2>=$start && \$2<$stop)print \$2}' region.$i.markers >> kk";
	#print $sys."\n";
	#system($sys);
	open(BUFF,"region.$i.markers") or die "no markers exists\n";
	open(BUFF1,"gunzip -c out.22.$i.c22.obs_mod.bgl.gz.gprobs.gz |") or die " no gprobs $i exists\n";
	$line = <BUFF1>;
	while(<BUFF>)
	{
		$line = <BUFF1>;
		chomp($_);
		@a = split(" ",$_);
		if($a[1] >= $start && $a[1] < $stop)
		{
			print WRBUFF $line;
		}	
	}
}

